package or.T0445;

public class ListNode {
    public int val;
    public ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
    public static ListNode setByArray(int [] array){
        ListNode head=new ListNode();
        ListNode tmp=head;
        for (int i = 0; i <array.length ; i++) {
            tmp.next=new ListNode(array[i]);
            tmp=tmp.next;
        }
        return head.next;
    }
    public void print(){
        System.out.print("ListNode: ");
        ListNode tmp=this;
        while (tmp!=null){
            System.out.print(tmp.val);
            tmp=tmp.next;
        }
        System.out.println();
    }
}


